#include <iostream>
#include <fstream>
#include <math.h>
#include <string.h>
#include <stdio.h>
#include <string>

using namespace std;

// Include GLEW
#include <GL/glew.h>

// Include GLFW
#include <GL/glfw.h>

// Include GLUT
#include <GL/glut.h>

// Include GLM
#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include <glm/gtc/quaternion.hpp>
#include <glm/gtx/quaternion.hpp>
#include <glm/gtx/euler_angles.hpp>
#include <glm/gtx/norm.hpp>

using namespace glm;

#include "shader.hpp"

#define SIZE 1442401

#define uint unsigned int

#ifndef GRID_HPP
#define GRID_HPP

class Grid
{
private:
    GLuint dataBuffer;
    short *data;

    GLuint elementBuffer;
    uint *element;
    uint elementBufferSize;

    int LOD;

    GLuint VertexArrayID;

    GLuint programID[2];
    GLuint MatrixID[2];

    short useProgram;

    mat4 MVP;

    void initGrid();
    void initGridGPU();

    void createGridLOD();
    void getGridLOD(float cameraHeight);
public:
    Grid();

    void drawGrid(mat4 VP, float cameraHeight);
    void cleanupGrid();

    void setView(short _view);
};

#endif
